/**
 * wait的使用
 */
public class WaitDemo_线程通讯 {
    public static void main(String[] args) {
        Object obj1 = new Object();
        Thread t = new Thread(()->{
            System.out.println("线程1开始执行");
            try {
                synchronized (obj1){
                    System.out.println("线程1调用wait方法....");
                    // 无限等待状态
                    obj1.wait();
                }
            } catch (InterruptedException e) { //接收到一个Interrupter异常
                e.printStackTrace();
            }
            System.out.println("线程1执行完成");
        },"线程1");
        t.start();
    }
}
